#include<bits/stdc++.h>
using namespace std;
long long n,a[200010],t,s;
long long p[200010],rp[200010];
void dfs(int x,int l0,int l1,long long ts)
{
    if(x==n+1)
    {
        s=max(ts,s);
        return;
    }
    if(rp[x]+ts<=s) return;
    if(a[x]==a[l0]||a[x]==a[l1])
    {
        if(a[x]==a[l0])
        {
            dfs(x+1,x,l1,ts+a[x]);
        }
        if(a[x]==a[l1])
        {
            dfs(x+1,l0,x,ts+a[x]);
        }
        return;
    }
    dfs(x+1,x,l1,ts);
    dfs(x+1,l0,x,ts);
}
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>t;
    while(t--)
    {
        s=0;
        memset(p,0,sizeof(p));
        cin>>n;
        long long tt=0;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
            p[i]=p[i-1]+a[i];
            tt+=a[i];
        }
        for(int i=1;i<=n;i++)
        {
            rp[i]=tt-p[i]+a[i];
        }
        dfs(2,1,0,0);
        cout<<s<<endl;
    }
    return 0;
}
